#!/bin/bash

if [ "$1" == "" ]; then
    echo "Usage: $0 <tag>"
    exit 1
fi

TAG=$1

LIBPATH=$TAG/out/target/common/obj/JAVA_LIBRARIES
for libdir in $(cd $LIBPATH; ls -1); do
    lib=${libdir%_intermediates}
    echo $lib
    mkdir -p ../$TAG/javalib
    if [ -f $LIBPATH/$libdir/classes.jar ]; then
        cp $LIBPATH/$libdir/classes.jar ../$TAG/javalib/$lib.jar
    else
        cp $LIBPATH/$libdir/javalib.jar ../$TAG/javalib/$lib.jar
    fi
done
